import axios from '@/libs/axios1';
import { escape2Html, html2Escape } from '@/libs/utils';
let jsonHeaders = { 'content-type': 'application/json;charset=UTF-8' };
import qs from 'qs';
const integration = '/integration3rd';

// 违规行为统计
export const behavior = (sceneId) => {
  return axios({
    url:`/compete/behavior/${sceneId}`,
    method:'get',
    headers:jsonHeaders,
  })
}
// 违规行为列表
export const behaviorList = (sceneId,params) => {
  return axios({
    url:`/compete/behavior/page/${sceneId}`,
    method: 'get',
    params,
    headers:jsonHeaders,
  })
}

// 添加违规行为
export const addBehavior = (params) => {
  return axios({
    url:`/compete/behavior`,
    method: 'post',
    data:params,
    headers:jsonHeaders,
  })
}

// 添加处理
export const addBehaviorDispose = (id,params) => {
  return axios({
    url:`/compete/behavior/dispose/${id}`,
    method: 'post',
    data:params,
    headers:jsonHeaders,
  })
}
// 处理记录列表
export const behaviorDisposeList = (id,params) => {
  return axios({
    url:`/compete/behavior/dispose/page/${id}`,
    method: 'get',
    params,
    headers:jsonHeaders,
  })
}

// 流量归档  获取数据列表
export const getFlowRecordList = (sceneId,params) => {
  return axios({
    url:`/compete/flowRecord/page/${sceneId}`,
    method: 'get',
    params,
    headers:jsonHeaders,
  })
}

// 流量归档  添加流量任务
export const addFlowRecord = (params) => {
  return axios({
    url:`/compete/flowRecord`,
    method: 'post',
    data:params,
    headers:jsonHeaders,
  })
}

// 流量归档  删除流量归档任务
export const deleteFlowRecord = (taskId) => {
  return axios({
    url:`/compete/flowRecord/${taskId}`,
    method: 'delete',
    headers:jsonHeaders,
  })
}

// 流量归档  停止流量归档任务
export const stopFlowRecord = (taskId) => {
  return axios({
    url:`/compete/flowRecord/${taskId}`,
    method: 'post',
    headers:jsonHeaders,
  })
}

// 流量归档  重新开始流量归档任务
export const restartFlowRecord = (taskId) => {
  return axios({
    url:`/compete/flowRecord/restart/${taskId}`,
    method: 'post',
    headers:jsonHeaders,
  })
}


// 根据任务id获取全流量文件 下载文件流
export const fullFlowDown = (taskId) => {
  return axios({
    url: `${integration}/trafficArchiving/${taskId}/down`,
    method: 'post',
    headers: {
      'Content-Type': 'application/json; application/octet-stream'
    },
    responseType: 'blob'
    // timeout:0
  })
}

// 根据工程id和类型 获取下载id 下载数据包前调用获取
export const machlakeTaskIdDown = (projectId, fileType, data) => {
  return axios({
    url: `${integration}/flow/machlake/${projectId}/bc/${fileType}`,
    data: data,
    method: 'post',
    headers: jsonHeaders
  })
}

// 根据工程id和类型 获取下载id 下载数据包前调用获取 新接口
export const trafficArchivingDown = (data) => {
  return axios({
    url: `${integration}/trafficArchiving`,
    data: data,
    method: 'post',
    headers: jsonHeaders
  })
}

// 根据任务id返回Minio文件id
export const trafficArchivingDownFileId = (taskId) => {
  return axios({
    url: `${integration}/trafficArchiving/${taskId}/downFileId`,
    method: 'get',
    headers: jsonHeaders
  })
}

// 查询全流量进度
export const trafficArchivingDownProgress = (taskId) => {
  return axios({
    url: `${integration}/trafficArchiving/${taskId}`,
    method: 'get',
    headers: jsonHeaders
  })
}

// 获取查询key值
export const sessionDetailKey = () => {
  return axios({
    url: `${integration}/comm/sessionDetail`,
    method: 'get',
    headers: jsonHeaders,
  })
}

// 查询应用层协议名称
export const appProtocols = () => {
  return axios({
    url: `${integration}/netBehaviors/appProtocols`,
    method: 'get',
    headers: jsonHeaders,
  })
}


// 根据不同的功能回去key value 和运算值
export const sessionKeyValue = (params) => {
  return axios({
    url: `${integration}/comm/dic`,
    method: 'get',
    params,
    headers: jsonHeaders,
  })
}



// 获取网络威胁事件列表
export const networkSecurity = (projectId,params) => {
  return axios({
    url:`${integration}/log/${projectId}/networkSecurity`,
    method: 'get',
    params,
    headers:jsonHeaders,
  })
}

// 流量检索列表 会话祥单
export const flowMachlake = (params) => {
  return axios({
    url:`${integration}/trafficRetrieval/sessionDetails`,
    method: 'post',
    data:params,
    headers:jsonHeaders,
  })
}

// 网络行为列表
export const netBehaviorsList = (params) => {
  return axios({
    url:`${integration}/netBehaviors`,
    method: 'get',
    params,
    headers:jsonHeaders,
  })
}

// 是否开启网络行为采集分析
export const openNetControl = (params) => {
  return axios({
    url:`${integration}/netBehaviors/control`,
    method: 'put',
    params,
    headers:jsonHeaders,
  })
}

// 查询网络行为采集分析的开启状态
export const queryNetControl = (params) => {
  return axios({
    url:`${integration}/netBehaviors/control/status`,
    method: 'get',
    params,
    headers:jsonHeaders,
  })
}

// 网络行为 文件提取
export const fileRestore = (id) => {
  return axios({
    url: `${integration}/netBehaviors/${id}/fileRestore`,
    method: 'post',
    headers: {
      'Content-Type': 'application/json; application/octet-stream'
    },
    responseType: 'blob',
    timeout:0
  })
}

// 获取离线任务列表
export const machlakeOfflineTask = (projectId,params) => {
  return axios({
    url:`${integration}/offlineTask/${projectId}/offlineTask`,
    method: 'get',
    params,
    headers:jsonHeaders,
  })
}

// 创建离线任务
export const addOfflineTask = (params) => {
  return axios({
    url:`${integration}/offlineTask/offlineTask`,
    method: 'post',
    data:params,
    headers:jsonHeaders,
  })
}


// 操作离线任务
export const activeOfflineTask = (taskId,active) => {
  console.log('🚀  activeOfflineTask ~ taskId:', taskId)
  return axios({
    url:`${integration}/offlineTask/${taskId}/offlineTask/${active}`,
    method: 'put',
    headers:jsonHeaders,
  })
}

// 
export const trafficStatisticsEchart = (taskId) => {
  return axios({
    url:`${integration}/trafficStatistics`,
    method: 'get',
    headers:jsonHeaders,
  })
}






































